package com.youpai.platform.user.service.enums;

import com.youpai.platform.common.enums.ProcessCodeEnum;
import com.youpai.platform.common.exceptions.BaseBizException;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;

/**
 * @date: 2022/7/23 12:18
 * @author: Anna
 * @version: 1.0
 * @description: 用户状态枚举类
 */
@AllArgsConstructor
@NoArgsConstructor
public enum UserStateEnum {

    ONLINE(1,"在线","在线"),
    OFFLINE(0,"离线","离线"),
    ;

    /**
     * 状态
     */
    public Integer state;

    /**
     * 状态标签
     */
    public String tag;

    /**
     * 描述
     */
    private String desc;


    /**
     * 根据code获取用户状态
     * @return 用户状态
     */
    public static UserStateEnum getUserStateByCode(Integer state){
        for (UserStateEnum userStateEnum : UserStateEnum.values()) {
            if(userStateEnum.state.equals(state)){
                return userStateEnum;
            }
        }
        throw new BaseBizException(ProcessCodeEnum.USER_STATE_NOT_VALID);
    }
}
